package cn.zwx.member.svc.controller.config;

import cn.zwx.base.entity.ResponseEntity;
import cn.zwx.member.svc.dto.MemberConfigSaveDTO;
import cn.zwx.member.svc.service.MemberConfigService;
import cn.zwx.member.svc.vo.MemberConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zhangwenxue
 */
@RestController
@Api(tags = "会员配置相关接口")
@RequestMapping("/member/config")
public class MemberConfigController {

    private final MemberConfigService memberConfigService;

    public MemberConfigController(MemberConfigService memberConfigService) {
        this.memberConfigService = memberConfigService;
    }

    @PutMapping("/save")
    @ApiOperation("保存会员配置")
    public ResponseEntity<Boolean> saveConfig(@Valid @RequestBody MemberConfigSaveDTO dto){

        return ResponseEntity.success(memberConfigService.saveConfig(dto));
    }


    @GetMapping("/get")
    @ApiOperation("获取会员配置信息")
    public ResponseEntity<MemberConfigVO> getConfig() {
        return ResponseEntity.success(memberConfigService.getConfig());
    };
}
